#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
int v;
int w;
int m;
int new_v[N];
int new_w[N];
int dp[N];
int main(){
	int n,W;
	cin>>n>>W; 
	int newi = 0;
	for(int i = 1;i<=n;i++){
		cin>>v>>w>>m;
		for(int j = 1;j<=m;j<<=1){
			m -= j;
			new_v[++newi] = j*v;
			new_w[newi] = j*w;
		}
		if(m){
			new_v[++newi] = m * v;
			new_w[newi] = m * w;
		}
	}
	for(int i = 1;i<=newi;i++){
		for(int j = W;j>=new_w[i];j--){
			dp[j] = max(dp[j],dp[j - new_w[i]] + new_v[i]);	
		}
	}
	cout<<dp[W];
	return 0;
} 
